package com.lin.fengxiu.vo;

import com.lin.fengxiu.model.BaseEntity;
import com.lin.fengxiu.model.Category;
import com.lin.fengxiu.model.Coupon;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Where;
import org.springframework.beans.BeanUtils;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * @ClassName Coupon
 * @Description TODO  优惠券实体类
 * @Author wushaopei
 * @Date 2021/3/23 22:39
 * @Version 1.0
 */
@Setter
@Getter
@NoArgsConstructor
public class CouponPureVO{
    @Id
    private Long id;
    private String title;
    private Date startTime;
    private Date endTime;
    private String description;
    private BigDecimal fullMoney;
    private BigDecimal minus;
    private BigDecimal rate;
    private Integer type;
    private String remark;
    private Boolean wholeStore;

    /**
     * @Description TODO 一组优惠券
     * @param objects
     */
    public CouponPureVO(Object[] objects){
        Coupon coupon = (Coupon)objects[0];
        BeanUtils.copyProperties(coupon,this);
    }

    /**
     * @Description TODO 单个优惠券
     * @param coupon
     */
    public CouponPureVO(Coupon coupon){
        BeanUtils.copyProperties(coupon,this);
    }

    public static List<CouponPureVO> getList(List<Coupon> couponList){
        List<CouponPureVO> vos = new ArrayList<>();
        return couponList.stream()
                .map(CouponPureVO::new)
                .collect(Collectors.toList());
    }

}
